<template>
  <div>
    <h3>子组件01</h3>
    <div>收到：{{msg}}</div>
  </div>
</template>

<script>
import pubsub from 'pubsub-js'

export default {
  name: "Child1-component",
  data(){
    return {
      msg:''
    }
  },
  mounted() {
    this.pubsubId = pubsub.subscribe('hello',(msgName,data)=>{
      console.log(msgName,data)
      this.msg = data
    })
  },
  beforeDestroy() {
    pubsub.unsubscribe(this.pubsubId)
  }
}
</script>

<style scoped>

</style>